const { Builder, Browser, By, Key, until } = require('selenium-webdriver');
const clipboardy = require('clipboardy');
async function readClipboard() {
    try {
        const text = await clipboardy.read();
        return text;
    } catch (err) {
        return null;
    }
}

(async function example() {
    let driver = await new Builder().forBrowser('chrome').build();
    let copyListText = []
    try {
        await driver.get('https://cs-going.com/zh/crosshair-library/');
        // 找到所有匹配的按钮
        let buttons = await driver.findElements(By.css('.p-4 .justify-between button'));
        // 循环点击
        for (let i = 0; i < buttons.length; i++) {
            buttons[i].click();
            copyListText[i] = await readClipboard()
        }
        console.log(copyListText);
        await driver.quit();
    } finally {
        // await driver.quit();
    }
})();